package com.bw.controller;


import com.bw.common.ResponseResult;
import com.bw.entity.ZkGoods;
import com.bw.service.IZkGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 莫晓晨
 * @since 2020-05-29
 */
@RestController
@RequestMapping("goods")
@CrossOrigin
public class ZkGoodsController {

    @Autowired
    private IZkGoodsService goodsService;

    @GetMapping("list")
    public ResponseResult list(){
        ResponseResult result = ResponseResult.SUCCESS();
        try {
            List<ZkGoods> goods = goodsService.list();
            result.setResult(goods);
            result.setMessage("success");
        }catch (Exception e){
            result.setSuccess(false);
            result.setMessage("defeat");
        }
        return result;
    }

}
